package com.my.objects;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

/**
 * @description:
 * @author: marshal
 * @date: 2021-08-24 2:32 PM
 */
public class WriteTeacher {
    public static void main(String[] args) {
        try (var oos = new ObjectOutputStream(new FileOutputStream("file/write_teacher.txt"))) {
            var p = new Person(500,"孙悟空");
            var t1 = new Teacher("唐僧", p);
            var t2 = new Teacher("菩提祖师", p);
            // 序列化
            oos.writeObject(t1);
            oos.writeObject(t2);
            oos.writeObject(p);
            oos.writeObject(t2);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
